﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Model;

namespace Hotfix
{
    [ObjectEvent(EventType.LoadUIInfo)]
    public class LoadUIInfo:IEvent
    {
        public async void Handle(int[] type, params object[] param)
        {
            Log.Info("事件：加载UI界面的具体数据");
            UIViewComponent Uvc = GameRoot.Scene.GetComponent<UIViewComponent>();
            Task t=GameRoot.GetSystem<UIViewSystem>().LoadViews();
            Log.Info("界面切换");
            object[] obj = ParamsHelper.GetObj(1);
            obj[0] = (int)UIViewType.Loading;
            await t;
            GameRoot.DispatcherSystem.Run(EventType.UIViewChange, null, obj);

        }
    }

    //UI界面切换事件
    [ObjectEvent(EventType.UIViewChange)]
    public class UIViewChange : IEvent
    {
        public void Handle(int[] type, params object[] param)
        {
            UIViewType temp = (UIViewType)param[0];
            Log.Info($"事件：切换界面至{temp}...");
            GameRoot.GetSystem<UIViewSystem>().LoadScene(temp);
        }
    }
}
